package study.domain.user;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 역활 계층 ID
 *
 * @author Barney Kim
 */
@Embeddable
@Data
@EqualsAndHashCode
public class RoleHierarchyId implements Serializable {

	private static final long serialVersionUID = 3992144998468218104L;

	@OneToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "parent_role", nullable = false, updatable = false)
	@org.hibernate.annotations.ForeignKey(name = "fk_roles_hierarchy_parent")
	private Role parentRole;

	@OneToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "child_role", nullable = false, updatable = false)
	@org.hibernate.annotations.ForeignKey(name = "fk_roles_hierarchy_child")
	private Role childRole;

	public RoleHierarchyId() {
	}

	public RoleHierarchyId(Role parentRole, Role childRole) {
		this.parentRole = parentRole;
		this.childRole = childRole;
	}
}
